package com.axx.android.setting;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.axx.android.LetterApp;
import com.axx.android.R;
import com.axx.android.base.BaseActivity;
import com.axx.android.home.activity.MainActivity;
import com.axx.android.profile.ModifyPwdActivity;
import com.axx.android.profile.SendFriendActivity;
import com.axx.android.profile.auth.activity.LoginActivity;
import com.axx.android.utils.ContextUtils;
import com.igexin.sdk.PushManager;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SettingActivity extends BaseActivity {


    @Bind(R.id.btn_back)
    Button btnBack;
    @Bind(R.id.layout_toolbar)
    RelativeLayout layoutToolbar;
    @Bind(R.id.layout_feed_back)
    LinearLayout layoutFeedBack;
    @Bind(R.id.layout_about_us)
    LinearLayout layoutAboutUs;
    @Bind(R.id.activity_setting)
    LinearLayout activitySetting;

    @Override
    public int getLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    public void init(Bundle savedInstanceState) {

    }


    @OnClick({R.id.layout_feed_back, R.id.layout_about_us,R.id.layout_sec,R.id.layout_out,R.id.layout_send_friend})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.layout_feed_back:
                startActivity(new Intent(this,FeedBackActivity.class));
                break;
            case R.id.layout_about_us:
                startActivity(new Intent(this,AboutUsActivity.class));
                break;
            case R.id.layout_sec:
                Intent intent =  new Intent(this,ModifyPwdActivity.class);
                startActivity(intent);
                break;
            case R.id.layout_out:
                showOutDialog();
                break;
            case R.id.layout_send_friend:
                startActivity(new Intent(this, SendFriendActivity.class));
                break;
        }
    }

    private void showOutDialog() {
        AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage("是否退出").setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                PushManager.getInstance().turnOffPush(SettingActivity.this);
                LetterApp.authUser = null;
                ContextUtils.clearUser(SettingActivity.this);
                Intent intent = new Intent(SettingActivity.this, MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        }).setNegativeButton("取消",null).create();
        alertDialog.show();
    }
}
